package com.pic4493.app;

import org.json.JSONObject;
import org.w3c.dom.Text;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.Toast;

import com.pic4493.base.BaseUITopBar;
import com.pic4493.comm.PubConst;
import com.pic4493.comm.Session;
import com.pic4493.utils.UtiQQSDK;
import com.tencent.connect.auth.QQAuth;
import com.tencent.tauth.IUiListener;
import com.tencent.tauth.Tencent;
import com.tencent.tauth.UiError;

public class UISignUp extends BaseUITopBar implements OnClickListener
{

   private ImageView mImgQQ;
   private ImageView mImgWeiBo;
   private ImageView mImgRenRen;
   private ImageView mImgEmail;

   private void initView()
   {
	  mImgQQ = (ImageView) findViewById(R.id.uisignup_img_tencent);
	  mImgWeiBo = (ImageView) findViewById(R.id.uisignup_img_weibo);
	  mImgRenRen = (ImageView) findViewById(R.id.uisignup_img_renren);
	  mImgEmail = (ImageView) findViewById(R.id.uisignup_img_email);
	  mImgQQ.setOnClickListener(this);
	  mImgWeiBo.setOnClickListener(this);
	  mImgRenRen.setOnClickListener(this);
	  mImgEmail.setOnClickListener(this);
   }

   @Override
   protected void onCreate(Bundle savedInstanceState)
   {
	  setContentView(R.layout.uisignup);
	  super.onCreate(savedInstanceState);
	  
	  setTitle("用户登录");
	  initView();
   }
   
   @Override
   public void onClick(View v)
   {
	  Intent uiIntent = new Intent();
	  switch (v.getId())
	  {
		 case R.id.uisignup_img_tencent:
			UtiQQSDK qq=new UtiQQSDK(mContext);
			qq.login();
			break;
		 case R.id.uisignup_img_weibo:
			uiIntent.setClass(mContext, UIWebLogin.class);
			uiIntent.putExtra(PubConst.Intent_Key.LoginType, PubConst.LoginType.WEIBO);
			startActivityForResult(uiIntent, PubConst.ActivityJump.LOGIN);
			break;
		 case R.id.uisignup_img_renren:
			Toast.makeText(UISignUp.this, "建设中", Toast.LENGTH_SHORT).show();
			break;
		 case R.id.uisignup_img_email:
			uiIntent.setClass(UISignUp.this, UILogin.class);
			startActivityForResult(uiIntent, PubConst.ActivityJump.LOGIN);
			break;
	  }
   }
   
   @Override
   protected void onActivityResult(int requestCode, int resultCode, Intent data)
   {
      if(requestCode==PubConst.ActivityJump.LOGIN)
      {
    	 if(resultCode==RESULT_OK)
    	 {
    		setResult(RESULT_OK);
    		finish();
    	 }
      }
   }
}
